/**
 * Created by wangzilong on 2017/4/11.
 */
import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Image,
    ScrollView,
    TouchableOpacity,
    TextInput,
    ListView,
    Modal,
    Platform
} from 'react-native';
import ImageWrapper from '../components/ImageWrapper';
var Dimensions = require('Dimensions');
const { width, height } = Dimensions.get('window');

export default class GoodsItem extends Component{
    render(){
        var hasInput = this.props.hasInput;
        return(
            <View style={[styles.goodsItemBox,this.props.style]}>
                <View style={styles.textBox}>
                    <Text style={{color:'#FF1010'}}>*</Text>
                    <Text>{this.props.title}</Text>
                </View>
                {hasInput?<View style={{flex:1}}>
                        <TextInput defaultValue={this.props.defaultValue}
                        underlineColorAndroid={'transparent'}
                        placeholder={this.props.placeholder}
                        style={styles.input}
                        onChangeText={this.props.onChangeText}
                        onBlur={this.props.onBlur}/>
                    </View>:<View style={[styles.textBox,{justifyContent:'flex-end',flex:1,marginLeft:20}]}>
                    <Text numberOfLines={1} style={{marginRight:10}}>{this.props.name}</Text>
                    <ImageWrapper width={16} height={16} icon={'right'} style={{marginRight:10}}/>
                </View>}
            </View>
        )
    }
}



const styles = StyleSheet.create({
    goodsItemBox:{
        flexDirection:'row',
        height:40,
        alignItems:'center',
        justifyContent:'space-between'
    },
    textBox:{
        flexDirection:'row',
        alignItems:'center',
        height:30,
        width:70
    },
    input:{
        marginLeft:20,
        flex:1,
        padding:3,
        fontSize:12,
        marginRight:30
    },
});